package com.suncaper.shop.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Service;

@Service
public class EmailService {
    @Autowired
    private JavaMailSender mailSender;

    @Value("${spring.mail.username}")
    private String from;

    public void sendMail(String title, String Content, String email) {
        SimpleMailMessage message = new SimpleMailMessage();
        message.setFrom(from);//发送人邮箱
        message.setSubject(title);//标题
        message.setTo(email);//收件人
        message.setText(Content);//邮件内容
        mailSender.send(message);//发送
    }
}
